package com.sky.mapper;

import com.github.pagehelper.Page;
import com.sky.annotation.AutoFill;
import com.sky.dto.CategoryPageQueryDTO;
import com.sky.entity.Category;
import com.sky.enumeration.OperationType;
import com.sky.result.PageResult;
import org.apache.ibatis.annotations.Delete;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Select;

import java.util.List;

@Mapper
public interface CategoryMapper {


    /**分页查询
     * @param categoryPageQueryDTO
     * @return
     */
    Page<Category> selectPage(CategoryPageQueryDTO categoryPageQueryDTO);


    /**
     * 更新category
     * @param category
     */
    @AutoFill(OperationType.UPDATE)
    void updateCategory(Category category);

    @Select("select * from category where type=#{type}")
    List<Category> selectCategoryByType(Integer type);

    @AutoFill(OperationType.INSERT)
    void insert(Category category);

    @Delete("delete from category where id=#{id}")
    void deleteById(Long id);

    @Select("select name from category where id=#{id}")
    String selectNameById(Long id);

    @Select("select * from category")
    List<Category> selectCategories();
}
